﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class UWBERROR : ViewBase
    {
        public VICC_WBERROR TMV
        {
            get
            {
                return (VICC_WBERROR)MV;
            }
        }



        public UWBERROR()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);

        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if(dwMaster==null)
            {
                KEY = "";
                ERVKEY = "";
            }
            else
            {
                KEY = dwMaster["RWKRS"].ToString() + dwMaster["RWLFD"].ToString() + dwMaster["RWPOS"].ToString();
                ERVKEY = dwMaster["RWKRS"].ToString() + dwMaster["RWLFD"].ToString() + dwMaster["RWPOS"].ToString()+"1";
            } 
        }
        public override void OnEXAUFChg(string value)
        {
            if (!IsCanLoad)
                return;
            TBMain.Clear();
            if (value == "")
                return;
            dwData = TBMain.NewRow();
            dwData["MANDANT"] = app.Mandant; 
            dwData["ART"] = " AND LO||LB||MDATE||WAKZ||ART||VAR||FARBE||FINISH||DESS||COLORIT='" + value.Substring(0,75) + "'";
            SResult = TMV.DWBERROR03(dwData);
            MergeData(SResult, false);
            base.OnEXAUFChg(value);
        }
        
    }
    public partial class UWBERROR
    {
        #region ==ERVKEY===========
        public static readonly DependencyProperty ERVKEYProperty = DependencyProperty.Register("ERVKEY",
            typeof(string), typeof(UWBERROR),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnERVKEYChanged));
        public string ERVKEY
        {
            get
            {
                return (string)GetValue(ERVKEYProperty);
            }
            set
            {
                SetValue(ERVKEYProperty, value);
                OnERVKEYChg();
            }
        }
        private static void OnERVKEYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UWBERROR;
            if (src != null)
            {
                src.ERVKEY = (string)e.NewValue;
            }
        }
        public virtual void OnERVKEYChg()
        {  
        }
        #endregion
    }
}
